<?php
/**
 * Created by PhpStorm.
 * User: CodeShuhao
 * Date: 2019/5/15
 * Time: 14:23
 */

namespace app\agent\controller;


use app\common\controller\Basic;

class BaseController extends Basic
{
    public $type = [
        1 => 'province',
        2 => 'city',
        3 => 'county',
        4 => '',
    ];

    public function __construct()
    {
        parent::__construct();

        //验证会话状态
        if( empty(session('uid')) )
        {
            $this->failure('请先登录！', url('Login/login'));
        }
        $this->assign('session_uid', session('uid'));

        //获取用户头像
        $head_img = db('user')->where('uid', session('uid'))->value('headimg');
        $this->assign('head_img', $head_img);
    }

    /**
     * 获取级别
     * @param $type
     * @return string
     */
    public function getNowType($type)
    {
        if( $type === 1 )
        {
            return 'city';
        }
        else if( $type === 2)
        {
            return 'county';
        }
    }

    public function getaddr()
    {
        $addr = new \app\common\controller\Addr();

        return $addr->getAddr();
    }

}